The following pages contain source code for a complete example demonstrating the use of TC/C++ object-oriented programming techniques. Each page contains a scrolling text field whose contents may be pasted into an individual source or header file for compilation. These text fields contain both TC and C++ versions, where different. In practice, conditional compilation* may be used to create programs which compile properly under both TC and C++ without modification.
As mentioned earlier, it is useful to place the declaration for each class in a separate header file (indicated by the extension '.h' in the file name) which may be accessed from the appropriate source files (indicated by the '.c' extension) using the #include preprocessor directive**. (Chapter 7 also discusses #define and the #ifndef directive used by C++ to prevent multiple references to the same header file.) For each class, the method definitions are usually contained in a separate source file. Finally, the 'main.c' source file contains the main() function where execution of the program begins.